package com.zis.auth.controller;

import com.zis.auth.service.ISercretInter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 服务器连接管理
 * Create by wangshen 2017/12/21
 */
@RestController
@RequestMapping("/api/sys/auth")
public class SercretController {

    @Autowired
    private ISercretInter sercretInter;


    /**
     * 生成服务器连接token
     * @param clientType
     * @param uiSign
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/{clientType}/conn/{uiSign}", method = RequestMethod.GET)
    @ResponseBody
    public String generater(@PathVariable("clientType") String clientType,
                            @PathVariable("uiSign") String uiSign) throws Exception {
        return sercretInter.generater(clientType, uiSign);
    }


    /**
     * 清空token
     * @param token
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/clear/{token}", method = RequestMethod.GET)
    @ResponseBody
    public String clear(@PathVariable("token") String token) throws Exception {
        return sercretInter.clear(token);
    }

    /**
     * 获取登陆信息
     * @param token
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/get/{token}", method = RequestMethod.GET)
    @ResponseBody
    public String getClient(@PathVariable("token") String token) throws Exception {
        return sercretInter.getClient(token);
    }

    /**
     * 获取短信验证码
     * @param telephone
     * @return
     */
    @RequestMapping(value = "/sms/{telephone}", method = RequestMethod.GET)
    @ResponseBody
    public String generateSmsCode(@PathVariable("telephone") String telephone) throws Exception {
        return sercretInter.getSmsCode(telephone);
    }
}
